Skip to content

Normalize severities and coerce non-string fields in summarize.py - #29

Merged
pierridotite merged 1 commit into
pierridotite:mainfrom
brixtonpham:fix/summarize-findings-normalization
Nov 26, 2026
Merged

pierridotite merged 1 commit into
pierridotite:mainfrom
brixtonpham:fix/summarize-findings-normalization

Conversation

@brixtonpham

Copy link
Copy Markdown
Contributor

Problem

In scripts/summarize.py, load() reads LLM-written findings.json files without normalizing severity or coercing non-string fields:

  1. Mixed-case severities are silently downgraded and misranked: unlike compare.py, draft_issues.py, and load_walkthrough(), load() does not .strip().lower() severity. Merging "BLOCKER" (rank fallback 9) with "minor" (2) downgrades the merged finding to "minor", and "Major" sorts below "cosmetic". Because scripts/notify.py consumes summarize.load(), Slack/Discord notifications inherit the same misranking.
  2. Non-string fields crash summary generation: if an agent writes "screen": ["02", "03"], "screen": 2, non-string "title", or non-list "issues" in findings.json, load() raises AttributeError / TypeError and aborts collect.sh.

Solution

  • Add a small text(x, default="") helper next to number(x) in scripts/summarize.py that coerces JSON values (None, bool, numbers, lists, whitespace-only strings) into trimmed strings (joining non-empty list entries with ", ", matching draft_issues.py's comma-separated Screen parsing).
  • Normalize severity to lowercase (text(i.get("severity"), "?").lower()), coerce title and screen via text(), and guard issues with isinstance(issues, list) in load().
  • Add regression tests in tests/test_summarize.py covering mixed-case severity merging/ranking (including notify.message()) and non-string field coercion, plus a bullet in CHANGELOG.md (## Unreleased).

Verification

  • /usr/bin/python3 -m unittest discover -s tests -q (Python 3.9.6): 277 tests OK (3 opt-in Playwright tests skipped)
  • Python 3.9 AST parse on touched files: OK

@pierridotite
pierridotite merged commit 3e4c979 into pierridotite:main Nov 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants